package com.eonmind.vip.controller;

import com.eonmind.common.contract.data.response.ResponseEntity;
import com.eonmind.common.security.annotations.UserInfo;
import com.eonmind.user.contract.dto.UserInfoData;
import com.eonmind.vip.dto.ClockDto;
import com.eonmind.vip.service.ClockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户签到
 */
@RestController
@RequestMapping("/clock")
public class ClockController {

    @Autowired
    ClockService clockService;

    /**
     * 用户签到打卡
     * @return ResponseEntity<Integer>
     * @ignoreParams userInfoData
     */
    @PostMapping("/userClock")
    @UserInfo
    public ResponseEntity<Integer> userClock(UserInfoData userInfoData) {
        return clockService.userClock(userInfoData);
    }

    /**
     * 判断用户当天是否签到
     * @return ResponseEntity<Boolean>
     * @ignoreParams userInfoData
     */
    @UserInfo
    @GetMapping("/isClock")
    public ResponseEntity<Boolean> isClock(UserInfoData userInfoData) {
        return clockService.isUserClocked(userInfoData);
    }

    /**
     * 统计以当天为起点用户连续签到天数
     * @return ResponseEntity<Integer>
     * @ignoreParams userInfoData
     */
    @UserInfo
    @GetMapping("/consecutiveClockDays")
    public ResponseEntity<Integer> getConsecutiveSignDays(UserInfoData userInfoData) {
        return clockService.getConsecutiveClockInDays(userInfoData);
    }

    /**
     * 获取本月签到记录
     *
     * @return ResponseEntity<List < String>>
     * @ignoreParams userInfoData
     */
    @UserInfo
    @GetMapping("/monthClockRecords")
    public ResponseEntity<List<ClockDto.ClockRecordsResponse>> getMonthSignRecords(UserInfoData userInfoData){
        return clockService.getMonthlyClockInRecords(userInfoData);
    }

}
